//
//  AStarFinder.h
//  TestAStart
//
//  Created by Sun Rujia on 11-11-17.
//  Copyright 2011 CDC Games. All rights reserved.
//

#import <Foundation/Foundation.h>

@class TilePoint;
@interface AStarFinder : NSObject {
	
	NSMutableArray *openTable;
	NSMutableArray *closeTable;
    NSMutableArray *runTable;
	TilePoint *startPoint;
	TilePoint *endPoint;
}
@property (retain) NSMutableArray *openTable;
@property (retain) NSMutableArray *closeTable;;
@property (retain) NSMutableArray *runTable;;

- (id)initWithTileCount:(NSInteger)tileCount;
- (BOOL)start:(TilePoint *)startPoint_ EndPoint:(TilePoint *)endPoint_;
- (TilePoint *)bestTilePoint:(TilePoint *)p;
- (BOOL)isComparePoint:(TilePoint *)p1 And:(TilePoint *)p2;
- (BOOL)isInOpenTable:(TilePoint *)p;
- (BOOL)isInCloseTable:(TilePoint *)p;
- (NSInteger)calculateHPower:(TilePoint *)p;
- (NSInteger)calculateGPower:(TilePoint *)p;
- (TilePoint *)getFromOpenPath:(TilePoint *)p;
- (BOOL)nextTile:(TilePoint *)curr X:(NSInteger)x Y:(NSInteger)y;
- (BOOL)isEnableTile:(NSInteger)x Y:(NSInteger)y;

- (void)setEnableTile:(NSArray *)tileCoordArray;
- (void)clearData;
@end

@interface TilePoint : NSObject
{
	NSInteger x;
	NSInteger y;
	NSInteger f;
	NSInteger g;
	NSInteger h;
	TilePoint *parent;
}
@property NSInteger x;
@property NSInteger y;
@property NSInteger f;
@property NSInteger g;
@property NSInteger h;
@property (retain) TilePoint *parent;

- (id)initWitTilePoint:(NSInteger)x Y:(NSInteger)y;

@end
